import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqDUurANh7KJe7RloPb3h\n' +
  'ARzeKxhXIm3QChvpOsz1Muvi6UUhVGWB4Z//EuQsmKBh7jIGmbrE7cMUIiy6UKAb\n' +
  'dEqDT57iya69PVExKtxAOtlPBTizwiaQ5YVWisTUaeEI705rhZq6buakidNgF4DB\n' +
  'K7OV02CInl1MJLqOzlSZZuVLdWSEuV2qQQPj8FDtWd4YGl89PqOtQIj9Imz/BYsl\n' +
  'P0JgJyZ+DlvGiMZfjbhMaa2xCPY67yLo+OsPiu+ZgH9x8B/YSjtseldF9610KUYV\n' +
  'PkfJwitj7reQ/wX/6Uael7JmqQJ0wGOT1Ns82tU0TG7jpWSb4mbtNLrcpSRe/k45\n' +
  'cQIDAQAB'

const privateKey = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCoNS6sA2Hsol7t\n' +
  'GWg9veEBHN4rGFcibdAKG+k6zPUy6+LpRSFUZYHhn/8S5CyYoGHuMgaZusTtwxQi\n' +
  'LLpQoBt0SoNPnuLJrr09UTEq3EA62U8FOLPCJpDlhVaKxNRp4QjvTmuFmrpu5qSJ\n' +
  '02AXgMErs5XTYIieXUwkuo7OVJlm5Ut1ZIS5XapBA+PwUO1Z3hgaXz0+o61AiP0i\n' +
  'bP8FiyU/QmAnJn4OW8aIxl+NuExprbEI9jrvIuj46w+K75mAf3HwH9hKO2x6V0X3\n' +
  'rXQpRhU+R8nCK2Put5D/Bf/pRp6XsmapAnTAY5PU2zza1TRMbuOlZJviZu00utyl\n' +
  'JF7+TjlxAgMBAAECggEAQyPPOEu1V43MFBmTGSnkWNxb9ZmmlhB8/Lv9UUIkESpE\n' +
  'jVXRou1NdXC2kKTRBC7oR/ph1hTNrBW0wJtX1vzBWJ6xYSOLZHNCB+qTlIc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ynH\n' +
  'RUf9yEtIJjmCfPSVPZe5S8vRoOL6Kfo8sw6CujNl1SMNjfp9lh2Hg53mqVFZkIwp\n' +
  '5wx11vj6LFYU6djR5UCMFizU+Mrx+zXor7QhpYt1DQaD0Ol9Yi00unXFb7K87aFq\n' +
  'FR3ioNVkPOYHDqI/g1+4rGU='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

